function count(text, pattern) {
  let times = 0;
  while (text.includes(pattern)) {
    times++;
    const start = text.indexOf(pattern) + 1;
    text = text.slice(start);
  }
  return times;
}


let output = count('she sells seashells by the seashore', 'sh');
output = count('101010101010101010101', '101');
console.log(output);